<!DOCTYPE html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <title>模块管理</title>
    <link href="../../../static/css/style.css" rel="stylesheet" type="text/css"/>
    <script type="text/javascript" src="../../../static/js/jquery.js"></script>
</head>
<script type="text/javascript">
    //数据回显
    $(function () {
        var moduleId = JSON.parse(localStorage.getItem("sysmoduleId"));
        $.ajax({
            type: "post",
            url: "/modules/moduleDetail2",
            data: {moduleId: moduleId},
            dataType: "JSON",
            success: function (rm) {
                //父模块查询
                $.ajax({
                    type: "post",
                    url: "/modules/moduleDetail2",
                    data: {modulePid:0},
                    dataType: "JSON",
                    success: function (rm) {
                        var moduleStr = '<option value="">请选择</option>';
                        for (let i = 0; i < rm.data.length; i++) {
                            if (moduleId == rm.data[i].moduleId) {
                                moduleStr += '<option selected="selected" value="' + rm.data[i].moduleId + '">' + rm.data[i].moduleRname + '</option>\n';
                            } else {
                                moduleStr += '<option value="' + rm.data[i].moduleId + '">' + rm.data[i].moduleRname + '</option>\n';
                            }
                        }
                        $("#modulePid").html(moduleStr);
                    },
                    error: function (rm) {
                        alert(rm.msg)
                    }
                });
                $("#moduleId").val(rm.data.moduleId);
                $("#moduleRname").val(rm.data.moduleRname);
                $("#moduleMurl").val(rm.data.moduleMurl);
            }
        });
    });

    function moduleSave() {
        $.ajax({
            type: "post",
            url: "/modules/updateModule",
            data: $("#Form").serializeArray(),
            traditional: true,
            async: true,
            dataType: "JSON",
            success: function () {
                window.location.href = "list";
            },
            error: function (rm) {
                alert(rm.msg);
            }
        });
    }
</script>
<body>
<form id="Form">
    <div class="place"><span>位置：</span>
        <ul class="placeul">
            <li><a href="../modules/list">系统管理</a></li>
            <li><a href="../modules/list">模块管理</a></li>
            <li><a href="../modules/moduleUpdate">修改</a></li>
        </ul>
    </div>
    <div class="formbody">
        <div class="formtitle"><span>模块信息</span></div>
        <ul class="forminfo">
          <li>
            <input name="moduleId" id="moduleId" type="hidden" value="" class="dfinput"/>
          </li>
            <li>
                <label>模块名称</label>
                <input name="moduleRname" id="moduleRname" type="text" value="用户管理" class="dfinput"/>
                <i>必填，不能超过30个字符</i>
            </li>
            <li>
                <label>父模块</label>
                <select name="modulePid" id="modulePid" class="dfselect">
                    <option value="" selected="selected">系统管理</option>
                    <option value="">营销管理</option>
                    <option value="">采购管理</option>
                </select>
            </li>
            <li>
                <label>URL</label>
                <input name="moduleMurl" id="moduleMurl" type="text" value="sys/users/userList.html" class="dfinput"/>
                <i>必填，不能超过30个字符</i>
            </li>
            <li>
                <label>&nbsp;</label>
                <input name="" onclick="moduleSave()" type="button" class="btn" value="确认保存"/>
                &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                <input name="" type="button" class="btn" value="返回" onclick="window.history.go(-1);"/>
            </li>
        </ul>
    </div>
</form>
</body>
